# -*- coding: UTF-8 -*-
"""
@Filename:exerc2.py
@author:Cora
@time:2025-03-21
"""
try:
    # 获取用户输入并转为浮点数
    height = float(input("请输入身高（单位：米）："))
    weight = float(input("请输入体重（单位：千克）："))

    if height <= 0 or weight <= 0:
        raise ValueError("身高或体重必须为正值")

    # 计算BMI
    bmi = weight / (height ** 2)
    print(f"BMI指数为: {bmi:.2f}")

    # 分类判断
    if bmi < 18.5:
        print("体重过轻")
    elif 18.5 <= bmi < 25:
        print("体重正常")
    elif 25 <= bmi < 28:
        print("体重过重")
    elif 28 <= bmi < 32:
        print("肥胖")
    else:
        print("严重肥胖")

except ValueError as e:
    print(f"输入错误：{e}（请输入数字且数值需大于0）")
